<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<title></title>
		<!-- 新 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css">

<!-- 可选的Bootstrap主题文件（一般不用引入） -->
<link rel="stylesheet" href="//cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap-theme.min.css">

<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
<script src="//cdn.bootcss.com/jquery/1.11.3/jquery.min.js"></script>

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="//cdn.bootcss.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>
		<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
	</head>
	<script>
	
	document.ontouchmove = function(e){ e.preventDefault(); };
	
	$(function(){
    var winWidth,winHeight;
    Resize = function(){
        winWidth = $(window).width();
        winHeight= $(window).height();
        
        
    }
});
				
		var flag = true;
		var t = 0;
		if (window.DeviceMotionEvent) {
			window.addEventListener('devicemotion', deviceMotionHandler, false);
		}
		var SHAKE_THRESHOLD = 900;
		var last_update = 0;
		var x, y, z, last_x, last_y, last_z;

		function deviceMotionHandler(eventData) {
				var acceleration = eventData.accelerationIncludingGravity;
				var curTime = new Date().getTime();
				if ((curTime - last_update) > 100) {
					var diffTime = curTime - last_update;
					last_update = curTime;
					x = acceleration.x;
					y = acceleration.y;
					z = acceleration.z;
					var speed = Math.abs(x + y + z - last_x - last_y - last_z) / diffTime * 10000;
					var status = document.getElementById("status");
					if (speed > SHAKE_THRESHOLD){
							if (flag == true) {
								flag = false;
								$("#bg").hide();
								$("#shaked1").show();
								$("#shaked2").show();
								$("#shaked1").animate({top:'-=80px'},500);
								$("#shaked2").animate({bottom:'-=80px'},500);
								$("#shaked1").animate({top:'+=80px'},500,function(){$(this).hide();});
								$("#shaked2").animate({bottom:'+=80px'},500,function(){$(this).hide();$("#bg").show();});
								
					
								
								$.post("<?php echo U('Index/shaked'); ?>", {
									openid:"<?php echo ($openid); ?>",
								}, function(data) {
									if(data=="err_1")
									alert("获取openid失败!");
									else
									alert(data);
									setTimeout(function(){
										flag=true;
									},3000);
								});
								
							}
						}
						last_x = x; last_y = y; last_z = z;
					}
				}
		
		
	</script>

	<body style="background-color: rgb(46,49,50);">
		
		<!--<div id="temp" style="font-size: xx-large;"></div> -->
		
		<div>
			<div style="margin-top:80px">
			<img id="shaked1"  style="display: none;position: relative;" height="100%" width="100%" src="__PUBLIC__/images/1.png"></img>
			<img id="shaked2" style="display: none;position: relative;" height="100%" width="100%" src="__PUBLIC__/images/2.png"></img>
			</div>
			<img id="bg" height="100%" width="100%" src="__PUBLIC__/images/3.png"></img>
			
		</div>
		
	</body>

</html>
